import {
	CalendarViewActionType,
	ICalendarViewAbility,
	ICalendarViewControllerParams,
	ICalendarViewModel,
	ICalendarViewStore,
	IParam,
	IViewEvent,
} from '@/core';
import { QXEvent } from 'qx-util';
import {
	getViewClassNames,
	handleQuickGroupValueChange,
	useViewAction,
	useViewBasic,
	useViewControllerParams,
	useViewProps,
} from '../use-view';

/**
 * 获取日历视图输入参数
 *
 * @export
 * @return {*}
 */
export function useCalendarViewProps() {
	return {
		...useViewProps(),
	};
}

/**
 * 获取日历视图基础
 *
 * @export
 * @param {ICalendarViewModel} model 日历视图模型
 * @param {IParam} props 输入参数
 * @return {*}
 */
export function useCalendarViewBasic(model: ICalendarViewModel, props: IParam) {
	const getSearchFormSlotName = (props: IParam) => {
		const showTabPageExp = App.getProjectSetting().multiTabsSetting.show;
		let searchFormSlotName = 'viewHeaderTop';
		if (!showTabPageExp && props.openType == 'ROUTE') {
			searchFormSlotName = 'viewHeaderBottom';
		}
		return searchFormSlotName;
	};
	const getClassNames = (props: IParam) => {
		return getViewClassNames(model, props);
	};
	return {
		...useViewBasic(model, props),
		getClassNames,
		getSearchFormSlotName,
		handleQuickGroupValueChange,
	};
}

/**
 * 日历视图行为
 *
 * @export
 */
export function useCalendarViewAction(controller: any) {
	return {
		...useViewAction(controller),
	};
}

/**
 * 获取日历视图控制器输入参数
 *
 * @export
 * @param {ICalendarViewModel} model
 * @param {IParam} props
 * @param {QXEvent<IViewEvent<CalendarViewActionType, ICalendarViewAbility>>} evt
 * @return {*}  {ICalendarViewControllerParams<CalendarViewActionType, ICalendarViewAbility>}
 */
export function useCalendarViewControllerParams(
	model: ICalendarViewModel,
	props: IParam,
	evt: QXEvent<IViewEvent<CalendarViewActionType, ICalendarViewAbility>>
): ICalendarViewControllerParams<CalendarViewActionType, ICalendarViewAbility> {
	return {
		...useViewControllerParams<ICalendarViewStore, ICalendarViewModel>(
			model,
			props,
			evt
		),
	};
}
